From ebdd393ba79980181e6c017834f1facc438d5a24 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Thu, 15 Aug 2013 18:02:50 +0000 Subject: [PATCH] Conrad removes implicit conversion to time_t. --- gpsbabel/alan.cc | 2 +- gpsbabel/an1.cc | 2 +- gpsbabel/cetus.cc | 2 +- gpsbabel/coastexp.cc | 6 +++--- gpsbabel/compegps.cc | 2 +- gpsbabel/copilot.cc | 2 +- gpsbabel/csv_util.cc | 16 +++++++++++++++- gpsbabel/delbin.cc | 12 ++++++------ gpsbabel/delgpl.cc | 2 +- gpsbabel/exif.cc | 12 ++++++------ gpsbabel/garmin.cc | 4 ++-- gpsbabel/garmin_txt.cc | 10 +++++----- gpsbabel/gcdb.cc | 2 +- gpsbabel/gdb.cc | 4 ++-- gpsbabel/geoniche.cc | 2 +- gpsbabel/ggv_log.cc | 4 ++-- gpsbabel/gnav_trl.cc | 2 +- gpsbabel/gopal.cc | 5 +++-- gpsbabel/gpilots.cc | 2 +- gpsbabel/gpspilot.cc | 2 +- gpsbabel/gpsutil.cc | 2 +- gpsbabel/gpx.cc | 4 ++-- gpsbabel/gtm.cc | 10 +++++----- gpsbabel/gtrnctr.cc | 16 ++++++++-------- gpsbabel/hiketech.cc | 4 ++-- gpsbabel/holux.cc | 2 +- gpsbabel/html.cc | 4 ++-- gpsbabel/humminbird.cc | 4 ++-- gpsbabel/igc.cc | 24 ++++++++++++------------ gpsbabel/ignrando.cc | 2 +- gpsbabel/igo8.cc | 2 +- gpsbabel/interpolate.cc | 10 +++++----- gpsbabel/itracku.cc | 2 +- gpsbabel/jtr.cc | 2 +- gpsbabel/kml.cc | 6 +++--- gpsbabel/lowranceusr.cc | 8 ++++---- gpsbabel/lowranceusr4.cc | 6 +++--- gpsbabel/magnav.cc | 8 ++++---- gpsbabel/magproto.cc | 8 ++++---- gpsbabel/main.cc | 2 +- gpsbabel/mapasia.cc | 2 +- gpsbabel/mapbar_track.cc | 8 +++----- gpsbabel/mapsend.cc | 2 +- gpsbabel/mapsource.cc | 12 ++++++------ gpsbabel/nmea.cc | 10 +++++----- gpsbabel/osm.cc | 2 +- gpsbabel/ozi.cc | 2 +- gpsbabel/palmdoc.cc | 6 +++--- gpsbabel/pathaway.cc | 4 ++-- gpsbabel/pcx.cc | 6 +++--- gpsbabel/pocketfms_bc.cc | 4 ++-- gpsbabel/psitrex.cc | 10 +++++----- gpsbabel/quovadis.cc | 2 +- gpsbabel/raymarine.cc | 2 +- gpsbabel/route.cc | 8 ++++---- gpsbabel/skyforce.cc | 2 +- gpsbabel/smplrout.cc | 4 ++-- gpsbabel/sort.cc | 2 +- gpsbabel/src/core/datetime.h | 11 ++++++++--- gpsbabel/stmsdf.cc | 14 +++++++------- gpsbabel/stmwpp.cc | 2 +- gpsbabel/subrip.cc | 10 +++++----- gpsbabel/text.cc | 4 ++-- gpsbabel/trackfilter.cc | 22 +++++++++++----------- gpsbabel/unicsv.cc | 22 +++++++++++----------- gpsbabel/vitosmt.cc | 2 +- gpsbabel/waypt.cc | 5 ++--- gpsbabel/wfff_xml.cc | 2 +- 68 files changed, 210 insertions(+), 193 deletions(-) diff --git a/gpsbabel/alan.cc b/gpsbabel/alan.cc index 42589974c..4165863c3 100644 --- a/gpsbabel/alan.cc +++ b/gpsbabel/alan.cc @@ -702,7 +702,7 @@ static int add_wpt(struct wprdata* wprdata, const waypoint* WP,int isroute) wpt->usecount = isroute ? 1 : 0; wpt->checked = isroute ? 0 : 1; wpt->reserved = 0; - pack_time(WP->GetCreationTime(), &(wpt->date), &(wpt->time)); + pack_time(WP->GetCreationTime().toTime_t(), &(wpt->date), &(wpt->time)); wpthdr->idx[hdr_idx] = wpt_idx; wpthdr->used[wpt_idx] = WPT_USED; diff --git a/gpsbabel/an1.cc b/gpsbabel/an1.cc index d8f65ac6f..b501a1211 100644 --- a/gpsbabel/an1.cc +++ b/gpsbabel/an1.cc @@ -798,7 +798,7 @@ Write_One_AN1_Waypoint(const waypoint* wpt) } - rec->creation_time = rec->modification_time = wpt->GetCreationTime(); + rec->creation_time = rec->modification_time = wpt->GetCreationTime().toTime_t(); rec->lat = EncodeOrd(wpt->latitude); rec->lon = EncodeOrd(-wpt->longitude); rec->serial = serial++; diff --git a/gpsbabel/cetus.cc b/gpsbabel/cetus.cc index 58f9fb032..d5d05e3b6 100644 --- a/gpsbabel/cetus.cc +++ b/gpsbabel/cetus.cc @@ -605,7 +605,7 @@ data_write(void) } file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = MYTYPE_WPT; /* CWpt */ file_out->creator = MYCREATOR; /* cGPS */ file_out->version = 1; diff --git a/gpsbabel/coastexp.cc b/gpsbabel/coastexp.cc index 5c2e3ade6..e25c0e54a 100644 --- a/gpsbabel/coastexp.cc +++ b/gpsbabel/coastexp.cc @@ -532,7 +532,7 @@ ce_gen_creation_time(time_t tm) static QString ce_gen_current_time(void) { - return ce_gen_creation_time(current_time()); + return ce_gen_creation_time(current_time().toTime_t()); } /* Generate a UUID (has same format as Microsoft registry GUIDs */ @@ -660,7 +660,7 @@ ce_mark_pr(const waypoint* wp) id = xml_buffer; } write_xml_entity_begin2(ofd, "\t", "Mark", - "created", ce_gen_creation_time(wp->GetCreationTime()), + "created", ce_gen_creation_time(wp->GetCreationTime().toTime_t()), "id", id); ce_waypt_pr(wp); write_xml_entity_end(ofd, "\t", "Mark"); @@ -699,7 +699,7 @@ ce_write(void) the standalone waypoints. */ time_t now = 0; - now = current_time(); + now = current_time().toTime_t(); write_xml_header(ofd); write_xml_entity_begin1(ofd, "", "NavObjectCollection", "created", diff --git a/gpsbabel/compegps.cc b/gpsbabel/compegps.cc index a0e46f2d8..233dc4161 100644 --- a/gpsbabel/compegps.cc +++ b/gpsbabel/compegps.cc @@ -564,7 +564,7 @@ write_trkpt_cb(const waypoint* wpt) // TOOD: This should probably attempt a gmtime and then fall back to the 1-1-1970 // case or bypass the time_t completely and build string representations directly. if (wpt->creation_time.isValid()) { - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); struct tm tm = *gmtime(&tt); strftime(buff, sizeof(buff), "%d-%b-%y %H:%M:%S", &tm); diff --git a/gpsbabel/copilot.cc b/gpsbabel/copilot.cc index 672672143..586931143 100644 --- a/gpsbabel/copilot.cc +++ b/gpsbabel/copilot.cc @@ -294,7 +294,7 @@ data_write(void) strncpy(file_out->name, out_fname, PDB_DBNAMELEN); file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = wayp_TYPE; file_out->creator = GXPU_CREATOR; file_out->version = 4; diff --git a/gpsbabel/csv_util.cc b/gpsbabel/csv_util.cc index 3c8700cfa..c24f893d5 100644 --- a/gpsbabel/csv_util.cc +++ b/gpsbabel/csv_util.cc @@ -910,6 +910,13 @@ writetime(char* buff, size_t bufsize, const char* format, time_t t, bool gmt) return strftime(buff, bufsize, format, stmp); } +static +int +writetime(char* buff, size_t bufsize, const char* format, const gpsbabel::DateTime& t, bool gmt) +{ + return writetime(buff, bufsize, format, t.toTime_t(), gmt); +} + static int writehms(char* buff, size_t bufsize, const char* format, time_t t, int gmt) @@ -932,6 +939,13 @@ writehms(char* buff, size_t bufsize, const char* format, time_t t, int gmt) (stmp->tm_hour>=12?"PM":"AM")); } +static +int +writehms(char* buff, size_t bufsize, const char* format, const gpsbabel::DateTime& t, int gmt) +{ + return writehms(buff, bufsize, format, t.toTime_t(), gmt); +} + static long time_to_yyyymmdd(QDateTime t) @@ -1907,7 +1921,7 @@ xcsv_waypt_pr(const waypoint* wpt) /* TIME CONVERSIONS**************************************************/ case XT_EXCEL_TIME: /* creation time as an excel (double) time */ - writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->GetCreationTime())); + writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->GetCreationTime().toTime_t())); break; case XT_TIMET_TIME: /* time as a time_t variable */ { diff --git a/gpsbabel/delbin.cc b/gpsbabel/delbin.cc index bb3e5e1d3..d5a59039c 100644 --- a/gpsbabel/delbin.cc +++ b/gpsbabel/delbin.cc @@ -1279,7 +1279,7 @@ get_gc_notes(const waypoint* wp, int* symbol, char** notes, unsigned* notes_size } logpart = xml_findfirst(curlog, "groundspeak:date"); if (logpart) { - time_t logtime = xml_parse_time(logpart->cdata); + time_t logtime = xml_parse_time(logpart->cdata).toTime_t(); const struct tm* logtm = gmtime(&logtime); gbfprintf(fd, "%d-%02d-%02d ", logtm->tm_year + 1900, logtm->tm_mon + 1, logtm->tm_mday); } @@ -1414,7 +1414,7 @@ write_waypoint(const waypoint* wp) waypoint_i++; le_write32(p->total, waypoint_n); le_write32(p->index, waypoint_i); - encode_time(wp->GetCreationTime(), &p->year); + encode_time(wp->GetCreationTime().toTime_t(), &p->year); le_write32(p->latitude, delbin_deg2rad(wp->latitude)); le_write32(p->longitude, delbin_deg2rad(wp->longitude)); if (wp->altitude > unknown_alt) { @@ -1713,7 +1713,7 @@ write_track_points(void) le_write32(p->index, i + 1); } assert(p); - encode_time(wp->GetCreationTime(), &p->point[j].year); + encode_time(wp->GetCreationTime().toTime_t(), &p->point[j].year); le_write32(p->point[j].latitude, delbin_deg2rad(wp->latitude)); le_write32(p->point[j].longitude, delbin_deg2rad(wp->longitude)); f = UNKNOWN_ELEV; @@ -1793,10 +1793,10 @@ write_track_end(const route_head* track) if (track->rte_name) { strncpy(p->name, track->rte_name, sizeof(p->name) - 1); } else { - sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime()); + sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t()); } le_write32(p->total_points, waypoint_n); - encode_time(current_time(), &p->year); + encode_time(current_time().toTime_t(), &p->year); le_write16(p->color, track_color_index(track->line_color.bbggrr)); le_write16(p->comment_size, comment_size); if (comment_size) { @@ -2186,7 +2186,7 @@ write_route_end(const route_head* route) if (route->rte_name) { strncpy(p->name, route->rte_name, sizeof(p->name) - 1); } else { - sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime()); + sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t()); } p->type = 0; le_write32(p->total_route_point, route_point_n); diff --git a/gpsbabel/delgpl.cc b/gpsbabel/delgpl.cc index a51c1d870..eb83d11e7 100644 --- a/gpsbabel/delgpl.cc +++ b/gpsbabel/delgpl.cc @@ -154,7 +154,7 @@ gpl_trackpt(const waypoint* wpt) le_write_double(&gp.alt, alt_feet); le_write_double(&gp.speed, speed); le_write_double(&gp.heading, heading); - le_write32(&gp.tm, wpt->GetCreationTime()); + le_write32(&gp.tm, wpt->GetCreationTime().toTime_t()); gbfwrite(&gp, sizeof(gp), 1, gplfile_out); } diff --git a/gpsbabel/exif.cc b/gpsbabel/exif.cc index 882342697..ff304143a 100644 --- a/gpsbabel/exif.cc +++ b/gpsbabel/exif.cc @@ -1112,7 +1112,7 @@ exif_find_wpt_by_time(const waypoint* wpt) if (exif_wpt_ref == NULL) { exif_wpt_ref = wpt; - } else if (abs(exif_time_ref - wpt->creation_time) < abs(exif_time_ref - exif_wpt_ref->creation_time)) { + } else if (abs(exif_time_ref - wpt->creation_time.toTime_t()) < abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t())) { exif_wpt_ref = wpt; } } @@ -1460,12 +1460,12 @@ exif_write(void) if (exif_wpt_ref == NULL) { warning(MYNAME ": No point with a valid timestamp found.\n"); - } else if (abs(exif_time_ref - exif_wpt_ref->creation_time) > frame) { + } else if (abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t()) > frame) { warning(MYNAME ": No matching point found for image date %s!\n", str); if (exif_wpt_ref != NULL) { - char* str = exif_time_str(exif_wpt_ref->creation_time); + char* str = exif_time_str(exif_wpt_ref->creation_time.toTime_t()); warning(MYNAME ": Best is from %s, %d second(s) away.\n", - str, abs(exif_time_ref - exif_wpt_ref->creation_time)); + str, abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t())); xfree(str); } exif_wpt_ref = NULL; @@ -1499,11 +1499,11 @@ exif_write(void) exif_put_double(GPS_IFD, GPS_IFD_TAG_ALT, 0, wpt->altitude); } - if (wpt->creation_time) { + if (wpt->creation_time.isValid()) { struct tm tm; char buf[32]; - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = *gmtime(&tt); tm.tm_year += 1900; diff --git a/gpsbabel/garmin.cc b/gpsbabel/garmin.cc index eab301650..cc8e3cd25 100644 --- a/gpsbabel/garmin.cc +++ b/gpsbabel/garmin.cc @@ -133,7 +133,7 @@ rw_init(const char* fname) * an affected unit. */ if (resettime) { - GPS_Command_Send_Time(fname, current_time()); + GPS_Command_Send_Time(fname, current_time().toTime_t()); return; } @@ -418,7 +418,7 @@ unsigned int checkWayPointIsAtSplit(waypoint* wpt, GPS_PLap* laps, int nlaps) int i; for (i=(nlaps-1); i >= 0; i--) { GPS_PLap lap = laps[i]; - time_t delta = lap->start_time - wpt->GetCreationTime(); + time_t delta = lap->start_time - wpt->GetCreationTime().toTime_t(); if ((delta >= -1) && (delta <= 1)) { result = 1; break; diff --git a/gpsbabel/garmin_txt.cc b/gpsbabel/garmin_txt.cc index 72349dfbd..922e5eb89 100644 --- a/gpsbabel/garmin_txt.cc +++ b/gpsbabel/garmin_txt.cc @@ -255,11 +255,11 @@ prework_wpt_cb(const waypoint* wpt) waypoint* prev = cur_info->prev_wpt; if (prev != NULL) { - cur_info->time += (wpt->GetCreationTime() - prev->GetCreationTime()); + cur_info->time += (wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t()); cur_info->length += waypt_distance_ex(prev, wpt); } else { cur_info->first_wpt = (waypoint*)wpt; - cur_info->start = wpt->GetCreationTime(); + cur_info->start = wpt->GetCreationTime().toTime_t(); } cur_info->prev_wpt = (waypoint*)wpt; cur_info->count++; @@ -618,7 +618,7 @@ write_waypt(const waypoint* wpt) print_string("%s\t", GMSD_GET(state, "")); country = gt_get_icao_country(GMSD_GET(cc, "")); print_string("%s\t", (country != NULL) ? country : ""); - print_date_and_time(wpt->GetCreationTime(), 0); + print_date_and_time(wpt->GetCreationTime().toTime_t(), 0); if (wpt->HasUrlLink()) { UrlLink l = wpt->GetUrlLink(); print_string("%s\t", l.url_); @@ -724,7 +724,7 @@ track_disp_wpt_cb(const waypoint* wpt) gbfprintf(fout, "Trackpoint\t"); print_position(wpt); - print_date_and_time(wpt->GetCreationTime(), 0); + print_date_and_time(wpt->GetCreationTime().toTime_t(), 0); if IS_VALID_ALT(wpt->altitude) { print_distance(wpt->altitude, 1, 0, 0); } @@ -738,7 +738,7 @@ track_disp_wpt_cb(const waypoint* wpt) if (prev != NULL) { float temp; gbfprintf(fout, "\t"); - delta = wpt->GetCreationTime() - prev->GetCreationTime(); + delta = wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t(); temp = WAYPT_GET(wpt, temperature, -999); if (temp != -999) { print_temperature(temp); diff --git a/gpsbabel/gcdb.cc b/gpsbabel/gcdb.cc index e24993e70..ec2f2f4ed 100644 --- a/gpsbabel/gcdb.cc +++ b/gpsbabel/gcdb.cc @@ -286,7 +286,7 @@ data_write(void) strncpy(file_out->name, "GeocachingDB", PDB_DBNAMELEN); file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = MYTYPE; /* CWpt */ file_out->creator = MYCREATOR; /* cGPS */ file_out->version = 1; diff --git a/gpsbabel/gdb.cc b/gpsbabel/gdb.cc index 0fa4f77d6..9efec606a 100644 --- a/gpsbabel/gdb.cc +++ b/gpsbabel/gdb.cc @@ -1404,7 +1404,7 @@ write_waypoint( FWRITE_i16(GMSD_GET(category, gdb_category)); FWRITE_DBL(WAYPT_GET(wpt, temperature, 0), 0); - FWRITE_TIME(wpt->GetCreationTime()); + FWRITE_TIME(wpt->GetCreationTime().toTime_t()); /* VERSION DEPENDENT CODE */ if (gdb_ver >= GDB_VER_3) { @@ -1586,7 +1586,7 @@ write_track(const route_head* trk, const char* trk_name) FWRITE_LATLON(wpt->latitude); FWRITE_LATLON(wpt->longitude); FWRITE_DBL(wpt->altitude, unknown_alt); - FWRITE_TIME(wpt->GetCreationTime()); + FWRITE_TIME(wpt->GetCreationTime().toTime_t()); d = WAYPT_GET(wpt, depth, unknown_alt); FWRITE_DBL(d, unknown_alt); d = WAYPT_GET(wpt, temperature, -99999); diff --git a/gpsbabel/geoniche.cc b/gpsbabel/geoniche.cc index a983ba5bd..d19789b66 100644 --- a/gpsbabel/geoniche.cc +++ b/gpsbabel/geoniche.cc @@ -822,7 +822,7 @@ data_write(void) file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + (49*365 + 17*366) * (60*60*24); + file_out->ctime = file_out->mtime = current_time().toTime_t() + (49*365 + 17*366) * (60*60*24); file_out->type = MYTYPE_ASC; file_out->creator = MYCREATOR; file_out->version = 0; diff --git a/gpsbabel/ggv_log.cc b/gpsbabel/ggv_log.cc index e8cfa33ad..71850ebca 100644 --- a/gpsbabel/ggv_log.cc +++ b/gpsbabel/ggv_log.cc @@ -223,7 +223,7 @@ ggv_log_track_head_cb(const route_head* trk) latsec = 60.0 * (latmin - floor(latmin)); lonsec = 60.0 * (lonmin - floor(lonmin)); - if (wpt->creation_time > 0) { + if (wpt->creation_time.isValid()) { time_t t = wpt->GetCreationTime().toTime_t(); tm = *gmtime(&t); tm.tm_mon += 1; @@ -238,7 +238,7 @@ ggv_log_track_head_cb(const route_head* trk) wpt->latitude, wpt->longitude); speed = waypt_speed(prev, wpt); } - if (wpt->creation_time > 0) { + if (wpt->creation_time.isValid()) { secs = (double)tm.tm_sec + wpt->GetCreationTime().time().msec() / 1000.0; } diff --git a/gpsbabel/gnav_trl.cc b/gpsbabel/gnav_trl.cc index 5abbca378..c48557847 100644 --- a/gpsbabel/gnav_trl.cc +++ b/gpsbabel/gnav_trl.cc @@ -118,7 +118,7 @@ gnav_trl_write_trkpt(const waypoint* wpt) { gnav_trl_t rec; - le_write32(&rec.time, wpt->GetCreationTime()); + le_write32(&rec.time, wpt->GetCreationTime().toTime_t()); le_write_float(&rec.lat, wpt->latitude); le_write_float(&rec.lon, wpt->longitude); if (wpt->altitude != unknown_alt) { diff --git a/gpsbabel/gopal.cc b/gpsbabel/gopal.cc index c3f305086..3bb16ce7d 100644 --- a/gpsbabel/gopal.cc +++ b/gpsbabel/gopal.cc @@ -314,7 +314,8 @@ gopal_read(void) //calculate the speed to reach this waypoint from the last. This way I try to sort out invalid waypoints speed=0; if (lastwpt !=NULL) { - speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / abs(wpt->creation_time - lastwpt->GetCreationTime()); + speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / + abs(wpt->creation_time.toTime_t() - lastwpt->GetCreationTime().toTime_t()); //printf("speed line %d %lf \n",line,speed); } /* Error handling: in the tracklog of my device sometimes "jump" waypoints ;-) */ @@ -372,7 +373,7 @@ gopal_write_waypt(const waypoint* wpt) } } //MSVC handles time_t as int64, gcc and mac only int32, so convert it: - timestamp=(unsigned long)wpt->GetCreationTime(); + timestamp=(unsigned long)wpt->GetCreationTime().toTime_t(); gbfprintf(fout, "%lu, %s, %lf, %lf, %5.1lf, %8.5lf, %d, %lf, %d\n",timestamp,tbuffer, wpt->longitude, wpt->latitude,wpt->altitude, wpt->speed,fix,wpt->hdop,wpt->sat); } diff --git a/gpsbabel/gpilots.cc b/gpsbabel/gpilots.cc index 4e732359a..64dae8a95 100644 --- a/gpsbabel/gpilots.cc +++ b/gpsbabel/gpilots.cc @@ -408,7 +408,7 @@ data_write(void) */ file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = MYWPT; file_out->creator = MYCREATOR; diff --git a/gpsbabel/gpspilot.cc b/gpsbabel/gpspilot.cc index c3dad5d8d..55f837865 100644 --- a/gpsbabel/gpspilot.cc +++ b/gpsbabel/gpspilot.cc @@ -209,7 +209,7 @@ data_write(void) } file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = MYTYPE_POINTS; file_out->creator = MYCREATOR; file_out->version = 0; diff --git a/gpsbabel/gpsutil.cc b/gpsbabel/gpsutil.cc index 7e8b621ce..f06825460 100644 --- a/gpsbabel/gpsutil.cc +++ b/gpsbabel/gpsutil.cc @@ -72,7 +72,7 @@ data_read(void) * Make sure that all waypoints in single read have same * timestamp. */ - time_t now = current_time(); + time_t now = current_time().toTime_t(); icon[0] = 0; while ((ibuf = gbfgetstr(file_in))) { diff --git a/gpsbabel/gpx.cc b/gpsbabel/gpx.cc index a8b5c64b4..410b726a8 100644 --- a/gpsbabel/gpx.cc +++ b/gpsbabel/gpx.cc @@ -1017,7 +1017,7 @@ gpx_end(void* data, const XML_Char* xml_el) waypt_alloc_gc_data(wpt_tmp)->placer = cdatastrp; break; case tt_cache_log_date: - gc_log_date = xml_parse_time(cdatastrp); + gc_log_date = xml_parse_time(cdatastrp).toTime_t(); break; /* * "Found it" logs follow the date according to the schema, @@ -1026,7 +1026,7 @@ gpx_end(void* data, const XML_Char* xml_el) */ case tt_cache_log_type: if ((0 == strcmp(cdatastrp, "Found it")) && - (0 == wpt_tmp->gc_data->last_found)) { + (0 == wpt_tmp->gc_data->last_found.toTime_t())) { waypt_alloc_gc_data(wpt_tmp)->last_found = gc_log_date; } gc_log_date = 0; diff --git a/gpsbabel/gtm.cc b/gpsbabel/gtm.cc index a7981a470..c8737207f 100644 --- a/gpsbabel/gtm.cc +++ b/gpsbabel/gtm.cc @@ -535,7 +535,7 @@ gtm_read(void) } fread_discard(file_in, 1); wpt->creation_time = fread_long(file_in); - if (wpt->creation_time) { + if (wpt->creation_time.isValid()) { wpt->creation_time += EPOCH89DIFF; } fread_discard(file_in, 2); @@ -563,7 +563,7 @@ gtm_read(void) wpt->longitude = fread_double(file_in); convert_datum(&wpt->latitude, &wpt->longitude); wpt->SetCreationTime(fread_long(file_in)); - if (wpt->creation_time) { + if (wpt->creation_time.isValid()) { wpt->creation_time += EPOCH89DIFF; } start_new = fread_byte(file_in); @@ -641,8 +641,8 @@ static void write_waypt(const waypoint* wpt) fwrite_string(file_out, wpt->description); fwrite_integer(file_out, icon_from_descr(wpt->icon_descr)); fwrite_byte(file_out, 3); - if (wpt->creation_time) { - fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF); + if (wpt->creation_time.isValid()) { + fwrite_long(file_out, wpt->GetCreationTime().toTime_t()-EPOCH89DIFF); } else { fwrite_long(file_out, 0); } @@ -665,7 +665,7 @@ static void write_trk_waypt(const waypoint* wpt) { fwrite_double(file_out, wpt->latitude); fwrite_double(file_out, wpt->longitude); - fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF); + fwrite_long(file_out, wpt->GetCreationTime().toTime_t()-EPOCH89DIFF); fwrite_byte(file_out, start_new); if (wpt->altitude == unknown_alt) { fwrite_single(file_out, unknown_alt_gtm); diff --git a/gpsbabel/gtrnctr.cc b/gpsbabel/gtrnctr.cc index 539367e34..737b15f4a 100644 --- a/gpsbabel/gtrnctr.cc +++ b/gpsbabel/gtrnctr.cc @@ -262,13 +262,13 @@ gtc_new_study_lap(const route_head* rte) static void gtc_study_lap(const waypoint* wpt) { - if (wpt->creation_time && (gtc_least_time == 0)) { + if (wpt->creation_time.isValid() && (!gtc_least_time.isValid())) { gtc_least_time = wpt->GetCreationTime(); gtc_start_lat = wpt->latitude; gtc_start_long = wpt->longitude; } - if (wpt->creation_time && (gtc_least_time > wpt->GetCreationTime())) { + if (wpt->creation_time.isValid() && (gtc_least_time > wpt->GetCreationTime())) { gtc_least_time = wpt->GetCreationTime(); gtc_start_lat = wpt->latitude; gtc_start_long = wpt->longitude; @@ -289,7 +289,7 @@ gtc_waypt_pr(const waypoint* wpt) gtc_write_xml(1, "\n"); } - if (wpt->creation_time) { + if (wpt->creation_time.isValid()) { QString time_string = wpt->CreationTimeXML(); if (!time_string.isEmpty()) { gtc_write_xml(0, "\n", @@ -340,8 +340,8 @@ static void gtc_fake_hdr(void) { long secs = 0; - if (gtc_least_time && gtc_most_time) { - secs = gtc_most_time - gtc_least_time; + if (gtc_least_time.isValid() && gtc_most_time.isValid()) { + secs = gtc_most_time.toTime_t() - gtc_least_time.toTime_t(); } /* write these in either case, course or activity format */ @@ -392,11 +392,11 @@ gtc_act_hdr(const route_head* rte) gtc_lap_start(NULL); gtc_new_study_lap(rte); route_disp(rte, gtc_study_lap); - if (gtc_least_time) { + if (gtc_least_time.isValid()) { gtc_write_xml(0, "%s\n", - gtc_least_time.toPrettyString().toUtf8().data()); + CSTR(gtc_least_time.toPrettyString())); gtc_write_xml(1, "\n", - gtc_least_time.toPrettyString().toUtf8().data()); + CSTR(gtc_least_time.toPrettyString())); } else { gtc_write_xml(1, "\n"); } diff --git a/gpsbabel/hiketech.cc b/gpsbabel/hiketech.cc index 13c3a7202..7f9488fff 100644 --- a/gpsbabel/hiketech.cc +++ b/gpsbabel/hiketech.cc @@ -130,8 +130,8 @@ static void hiketech_trkpt_pr(const waypoint* waypointp) { gbfprintf(ofd, " \n"); - if (waypointp->creation_time) { - hiketech_print_utc(waypointp->GetCreationTime(), " ", "utc"); + if (waypointp->creation_time.isValid()) { + hiketech_print_utc(waypointp->GetCreationTime().toTime_t(), " ", "utc"); } gbfprintf(ofd, " %f\n", waypointp->latitude); gbfprintf(ofd, " %f\n", waypointp->longitude); diff --git a/gpsbabel/holux.cc b/gpsbabel/holux.cc index 96fcf8af1..3572ae293 100644 --- a/gpsbabel/holux.cc +++ b/gpsbabel/holux.cc @@ -225,7 +225,7 @@ static void holux_disp(const waypoint* wpt) } /*set the time */ - if (wpt->creation_time) { + if (wpt->creation_time.isValid()) { /* tm = gmtime(&wpt->creation_time);*/ /* I get the wrong result with gmtime ??? */ QDate date(wpt->GetCreationTime().date()); QTime time(wpt->GetCreationTime().time()); diff --git a/gpsbabel/html.cc b/gpsbabel/html.cc index 85583ee73..b3688367e 100644 --- a/gpsbabel/html.cc +++ b/gpsbabel/html.cc @@ -81,7 +81,7 @@ html_disp(const waypoint* wpt) { char tbuf[1024]; char* cout; - time_t tm = wpt->GetCreationTime(); + time_t tm = wpt->GetCreationTime().toTime_t(); int32_t utmz; double utme, utmn; char utmzc; @@ -187,7 +187,7 @@ html_disp(const waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:date"); if (logpart) { - logtime = xml_parse_time(logpart->cdata); + logtime = xml_parse_time(logpart->cdata).toTime_t(); logtm = localtime(&logtime); if (logtm) { gbfprintf(file_out, diff --git a/gpsbabel/humminbird.cc b/gpsbabel/humminbird.cc index 73b078573..17f848d6c 100644 --- a/gpsbabel/humminbird.cc +++ b/gpsbabel/humminbird.cc @@ -716,7 +716,7 @@ humminbird_write_waypoint(const waypoint* wpt) hum.depth = si_round(WAYPT_GET(wpt, depth, 0)*100.0); be_write16(&hum.depth, hum.depth); - be_write32(&hum.time, wpt->GetCreationTime()); + be_write32(&hum.time, wpt->GetCreationTime().toTime_t()); east = wpt->longitude / 180.0 * EAST_SCALE; be_write32(&hum.east, si_round((east))); @@ -817,7 +817,7 @@ humminbird_track_cb(const waypoint* wpt) north = si_round(inverse_gudermannian_i1924(lat)); if (wpt->creation_time.isValid()) { - last_time = wpt->GetCreationTime(); + last_time = wpt->GetCreationTime().toTime_t(); } if (i == 0) { diff --git a/gpsbabel/igc.cc b/gpsbabel/igc.cc index 52375aecf..983f471b0 100644 --- a/gpsbabel/igc.cc +++ b/gpsbabel/igc.cc @@ -581,8 +581,8 @@ static void wr_header(void) track = pres_track; } // Date in header record is that of the first fix record - date = !track ? current_time() : - ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->GetCreationTime(); + date = !track ? current_time().toTime_t() : + ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->GetCreationTime().toTime_t(); if (NULL == (tm = gmtime(&date))) { fatal(MYNAME ": Bad track timestamp\n"); @@ -648,7 +648,7 @@ static void wr_task_hdr(const route_head* rte) fatal(MYNAME ": Too much waypoints (more than 99) in task route.\n"); } // Gather data to write to the task identification (first) record - rte_time = wpt->GetCreationTime() ? wpt->GetCreationTime() : current_time(); + rte_time = wpt->GetCreationTime().isValid() ? wpt->GetCreationTime().toTime_t() : current_time().toTime_t(); if (NULL == (tm = gmtime(&rte_time))) { fatal(MYNAME ": Bad task route timestamp\n"); } @@ -692,7 +692,7 @@ static void wr_fix_record(const waypoint* wpt, int pres_alt, int gnss_alt) { struct tm* tm; - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = gmtime(&tt); if (NULL == tm) { @@ -742,7 +742,7 @@ static int correlate_tracks(const route_head* pres_track, const route_head* gnss return 0; } } while (alt_diff > -10.0); - pres_time = ((waypoint*) elem->next)->GetCreationTime(); + pres_time = ((waypoint*) elem->next)->GetCreationTime().toTime_t(); if (global_opts.debug_level >= 1) { printf(MYNAME ": pressure landing time %s", ctime(&pres_time)); } @@ -758,7 +758,7 @@ static int correlate_tracks(const route_head* pres_track, const route_head* gnss return 0; } // Get a crude indication of groundspeed from the change in lat/lon - time_diff = wpt->GetCreationTime() - ((waypoint*) elem)->GetCreationTime(); + time_diff = wpt->GetCreationTime().toTime_t() - ((waypoint*) elem)->GetCreationTime().toTime_t(); speed = !time_diff ? 0 : (fabs(wpt->latitude - ((waypoint*) elem)->latitude) + fabs(wpt->longitude - ((waypoint*) elem)->longitude)) / time_diff; @@ -766,7 +766,7 @@ static int correlate_tracks(const route_head* pres_track, const route_head* gnss printf(MYNAME ": speed=%f\n", speed); } } while (speed < 0.00003); - gnss_time = ((waypoint*) elem->next)->GetCreationTime(); + gnss_time = ((waypoint*) elem->next)->GetCreationTime().toTime_t(); if (global_opts.debug_level >= 1) { printf(MYNAME ": gnss landing time %s", ctime(&gnss_time)); } @@ -797,7 +797,7 @@ static double interpolate_alt(const route_head* track, time_t time) curr_elem = prev_elem = QUEUE_FIRST(&track->waypoint_list); } // Find the track points either side of the requested time - while (((waypoint*) curr_elem)->GetCreationTime() < time) { + while (((waypoint*) curr_elem)->GetCreationTime().toTime_t() < time) { if (QUEUE_LAST(&track->waypoint_list) == curr_elem) { // Requested time later than all track points, we can't interpolate return unknown_alt; @@ -810,7 +810,7 @@ static double interpolate_alt(const route_head* track, time_t time) curr_wpt = (waypoint*) curr_elem; if (QUEUE_FIRST(&track->waypoint_list) == curr_elem) { - if (curr_wpt->GetCreationTime() == time) { + if (curr_wpt->GetCreationTime().toTime_t() == time) { // First point's creation time is an exact match so use it's altitude return curr_wpt->altitude; } else { @@ -819,12 +819,12 @@ static double interpolate_alt(const route_head* track, time_t time) } } // Interpolate - if (0 == (time_diff = curr_wpt->GetCreationTime() - prev_wpt->GetCreationTime())) { + if (0 == (time_diff = curr_wpt->GetCreationTime().toTime_t() - prev_wpt->GetCreationTime().toTime_t())) { // Avoid divide by zero return curr_wpt->altitude; } alt_diff = curr_wpt->altitude - prev_wpt->altitude; - return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->GetCreationTime()); + return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->GetCreationTime().toTime_t()); } /* @@ -861,7 +861,7 @@ static void wr_track(void) // Iterate through waypoints in both tracks simultaneously QUEUE_FOR_EACH(&gnss_track->waypoint_list, elem, tmp) { wpt = (waypoint*) elem; - pres_alt = interpolate_alt(pres_track, wpt->GetCreationTime() + time_adj); + pres_alt = interpolate_alt(pres_track, wpt->GetCreationTime().toTime_t() + time_adj); wr_fix_record(wpt, (int) pres_alt, (int) wpt->altitude); } } else { diff --git a/gpsbabel/ignrando.cc b/gpsbabel/ignrando.cc index 62fbd15e1..0e1b5a6b2 100644 --- a/gpsbabel/ignrando.cc +++ b/gpsbabel/ignrando.cc @@ -263,7 +263,7 @@ ignr_write(void) } track_num = 0; - now = current_time(); + now = current_time().toTime_t(); tm = *localtime(&now); gbfprintf(fout, "\n"); diff --git a/gpsbabel/igo8.cc b/gpsbabel/igo8.cc index 228560d9d..4de57a4d4 100644 --- a/gpsbabel/igo8.cc +++ b/gpsbabel/igo8.cc @@ -217,7 +217,7 @@ static void write_igo8_track_point(const waypoint* wpt) // then we shall make our own, where each point is one // second apart. if (wpt->creation_time.isValid()) { - le_write32(&point.unix_time, wpt->GetCreationTime()); + le_write32(&point.unix_time, wpt->GetCreationTime().toTime_t()); } else { le_write32(&point.unix_time, invented_time++); } diff --git a/gpsbabel/interpolate.cc b/gpsbabel/interpolate.cc index a660ca0c0..caf380905 100644 --- a/gpsbabel/interpolate.cc +++ b/gpsbabel/interpolate.cc @@ -93,9 +93,9 @@ interpfilt_process(void) first = 0; } else { if (opt_interval && - wpt->creation_time - time1 > interval) { + wpt->creation_time.toTime_t() - time1 > interval) { for (timen = time1+interval; - timen < wpt->creation_time; + timen < wpt->creation_time.toTime_t(); timen += interval) { waypoint* wpt_new = waypt_dupe(wpt); wpt_new->creation_time = timen; @@ -109,7 +109,7 @@ interpfilt_process(void) linepart(lat1, lon1, wpt->latitude, wpt->longitude, (double)(timen-time1)/ - (double)(wpt->creation_time-time1), + (double)(wpt->creation_time.toTime_t() - time1), &wpt_new->latitude, &wpt_new->longitude); if (opt_route) { @@ -131,7 +131,7 @@ interpfilt_process(void) distn += dist) { waypoint* wpt_new = waypt_dupe(wpt); wpt_new->creation_time = distn/curdist* - (wpt->creation_time - time1) + time1; + (wpt->creation_time.toTime_t() - time1) + time1; if (wpt_new->shortname) { xfree(wpt_new->shortname); } @@ -161,7 +161,7 @@ interpfilt_process(void) lat1 = wpt->latitude; lon1 = wpt->longitude; - time1 = wpt->creation_time; + time1 = wpt->creation_time.toTime_t(); } } route_flush(backuproute); diff --git a/gpsbabel/itracku.cc b/gpsbabel/itracku.cc index c875a859b..f5bd46111 100644 --- a/gpsbabel/itracku.cc +++ b/gpsbabel/itracku.cc @@ -307,7 +307,7 @@ to_itracku_data_record(const waypoint* wp, itracku_data_record* d) { le_write32(d->longitude, deg_to_deg_min(wp->longitude)); le_write32(d->latitude, deg_to_deg_min(wp->latitude)); - le_write32(d->creation_time, encode_itracku_time(wp->creation_time)); + le_write32(d->creation_time, encode_itracku_time(wp->creation_time.toTime_t())); d->speed = MPS_TO_KNOTS(wp->speed); le_write16(d->altitude, wp->altitude); d->flag = 0xff; diff --git a/gpsbabel/jtr.cc b/gpsbabel/jtr.cc index 48ec3be4c..9fb7a7e7f 100644 --- a/gpsbabel/jtr.cc +++ b/gpsbabel/jtr.cc @@ -272,7 +272,7 @@ jtr_trkpt_disp_cb(const waypoint* wpt) struct tm tm; if (wpt->creation_time.isValid()) { - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = *gmtime(&tt); tm.tm_year += 1900; diff --git a/gpsbabel/kml.cc b/gpsbabel/kml.cc index f28e2a516..40d6ee0f4 100644 --- a/gpsbabel/kml.cc +++ b/gpsbabel/kml.cc @@ -1930,7 +1930,7 @@ void kml_write(void) writer->writeStartElement("Document"); - now = current_time(); + now = current_time().toTime_t(); strftime(import_time, sizeof(import_time), "%c", localtime(&now)); if (realtime_positioning) { writer->writeTextElement("name", "GPS position"); @@ -2091,7 +2091,7 @@ kml_wr_position(waypoint* wpt) track_add_head(posn_trk_head); } - if (last_valid_fix == 0) { + if (!last_valid_fix.isValid()) { last_valid_fix = current_time(); } @@ -2117,7 +2117,7 @@ kml_wr_position(waypoint* wpt) last_valid_fix = wpt->GetCreationTime(); } - wpt->icon_descr = kml_get_posn_icon(wpt->GetCreationTime() - last_valid_fix); + wpt->icon_descr = kml_get_posn_icon(wpt->GetCreationTime().toTime_t() - last_valid_fix.toTime_t()); /* In order to avoid clutter while we're sitting still, don't add diff --git a/gpsbabel/lowranceusr.cc b/gpsbabel/lowranceusr.cc index e1a15331c..c66f14720 100644 --- a/gpsbabel/lowranceusr.cc +++ b/gpsbabel/lowranceusr.cc @@ -415,7 +415,7 @@ lowranceusr_parse_waypt(waypoint* wpt_tmp) if (global_opts.debug_level >= 2) { printf(MYNAME " parse_waypt: creation time %d\n", - (int)wpt_tmp->creation_time); + (int)wpt_tmp->creation_time.toTime_t()); printf(MYNAME " parse_waypt: base_time %d\n", (int)base_time_secs); printf(MYNAME " parse_waypt: waypt time %d\n", (int)waypt_time); } @@ -749,8 +749,8 @@ lowranceusr_waypt_disp(const waypoint* wpt) gbfputint32(text_len, file_out); } - if (wpt->creation_time > base_time_secs) { - Time = wpt->creation_time - base_time_secs; + if (wpt->creation_time.toTime_t() > base_time_secs) { + Time = wpt->creation_time.toTime_t() - base_time_secs; } else { Time = 0; } @@ -758,7 +758,7 @@ lowranceusr_waypt_disp(const waypoint* wpt) if (global_opts.debug_level >= 2) { time_t wpt_time = Time; printf(MYNAME " waypt_disp: base_time : %d\n", (int)base_time_secs); - printf(MYNAME " waypt_disp: creation time : %d\n", (int)wpt->creation_time); + printf(MYNAME " waypt_disp: creation time : %d\n", (int)wpt->creation_time.toTime_t()); printf(MYNAME " waypt_disp: waypt time : %d\n", (int)wpt_time); printf(MYNAME " waypt_disp: waypt time (local): %s\n", ctime(&wpt_time)); } diff --git a/gpsbabel/lowranceusr4.cc b/gpsbabel/lowranceusr4.cc index 8fd978177..4dc8f1184 100644 --- a/gpsbabel/lowranceusr4.cc +++ b/gpsbabel/lowranceusr4.cc @@ -810,8 +810,8 @@ lowranceusr4_waypt_disp(const waypoint* wpt) gbfputflt(WAYPT_GET(wpt, proximity, 0.0), file_out); /* Creation date/time */ - gbfputint32(lowranceusr4_jd_from_timestamp(wpt->GetCreationTime()), file_out); - gbfputint32(wpt->GetCreationTime(), file_out); + gbfputint32(lowranceusr4_jd_from_timestamp(wpt->GetCreationTime().toTime_t()), file_out); + gbfputint32(wpt->GetCreationTime().toTime_t(), file_out); /* Unused byte */ gbfputc(0, file_out); @@ -982,7 +982,7 @@ lowranceusr4_write_track_waypt(const waypoint* wpt) gbfputc(0, file_out); /* Timestamp */ - gbfputint32(wpt->GetCreationTime(), file_out); + gbfputint32(wpt->GetCreationTime().toTime_t(), file_out); /* Long/Lat */ gbfputdbl(wpt->longitude * DEGREESTORADIANS, file_out); diff --git a/gpsbabel/magnav.cc b/gpsbabel/magnav.cc index df2dabf8a..e0ba75c5e 100644 --- a/gpsbabel/magnav.cc +++ b/gpsbabel/magnav.cc @@ -142,12 +142,12 @@ my_writewpt(const waypoint* wpt) time_t tm_t; struct tm* tm; tm = NULL; - if (wpt->creation_time) { - const time_t tt = wpt->creation_time; + if (wpt->creation_time.isValid()) { + const time_t tt = wpt->creation_time.toTime_t(); tm = gmtime(&tt); } if (!tm) { - tm_t = current_time(); + tm_t = current_time().toTime_t(); tm = gmtime(&tm_t); } @@ -226,7 +226,7 @@ data_write(void) strncpy(file_out->name, "Companion Waypoints", PDB_DBNAMELEN); file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = MYTYPE; /* CWpt */ file_out->creator = MYCREATOR; /* cGPS */ file_out->version = 1; diff --git a/gpsbabel/magproto.cc b/gpsbabel/magproto.cc index 2669fd75b..454a8d7cf 100644 --- a/gpsbabel/magproto.cc +++ b/gpsbabel/magproto.cc @@ -728,7 +728,7 @@ mag_serial_init_common(const char* portname) mag_handon(); } - now = current_time(); + now = current_time().toTime_t(); /* * The 315 can take up to 4.25 seconds to respond to initialization * commands. Time out on the side of caution. @@ -739,7 +739,7 @@ mag_serial_init_common(const char* portname) while (!got_version) { mag_readmsg(trkdata); - if (current_time() > later) { + if (current_time().toTime_t() > later) { fatal(MYNAME ": No acknowledgment from GPS on %s\n", portname); } @@ -1441,8 +1441,8 @@ void mag_track_disp(const waypoint* waypointp) ilat = waypointp->latitude; ilon = waypointp->longitude; tm = NULL; - if (waypointp->creation_time) { - const time_t ct = waypointp->GetCreationTime(); + if (waypointp->creation_time.isValid()) { + const time_t ct = waypointp->GetCreationTime().toTime_t(); tm = gmtime(&ct); if (tm) { hms = tm->tm_hour * 10000 + tm->tm_min * 100 + diff --git a/gpsbabel/main.cc b/gpsbabel/main.cc index bdd8862c9..938fd1b75 100644 --- a/gpsbabel/main.cc +++ b/gpsbabel/main.cc @@ -254,7 +254,7 @@ main(int argc, char* argv[]) global_opts.inifile = NULL; gpsbabel_now = time(NULL); /* gpsbabel startup-time */ - gpsbabel_time = current_time(); /* same like gpsbabel_now, but freezed to zero during testo */ + gpsbabel_time = current_time().toTime_t(); /* same like gpsbabel_now, but freezed to zero during testo */ #ifdef DEBUG_MEM debug_mem_open(); diff --git a/gpsbabel/mapasia.cc b/gpsbabel/mapasia.cc index 893697dea..f4259ac9d 100644 --- a/gpsbabel/mapasia.cc +++ b/gpsbabel/mapasia.cc @@ -133,7 +133,7 @@ tr7_read(void) } if (prev) { /* other track or bad timestamp */ - if (wpt->creation_time && (prev->creation_time > wpt->creation_time)) { + if (wpt->creation_time.isValid() && (prev->creation_time.toTime_t() > wpt->creation_time.toTime_t())) { trk = NULL; } else if (waypt_distance(prev, wpt) > 9999.9) { trk = NULL; diff --git a/gpsbabel/mapbar_track.cc b/gpsbabel/mapbar_track.cc index 0831b1a5f..e74739bf6 100644 --- a/gpsbabel/mapbar_track.cc +++ b/gpsbabel/mapbar_track.cc @@ -50,7 +50,7 @@ mapbar_track_rd_deinit(void) } static gpsbabel::DateTime -read_time_t(void) +read_datetime(void) { int hour = gbfgetint16(fin); int min = gbfgetint16(fin); @@ -85,10 +85,8 @@ mapbar_track_read(void) is_fatal((track == NULL), MYNAME ": memory non-enough"); track_add_head(track); - time_t start_time = read_time_t(); - (void) start_time; // currently not used. - time_t end_time = read_time_t(); - (void) end_time; // currently not used. + (void) read_datetime(); // start_time currently unused + (void) read_datetime(); // end_time currently unused char name[200] = {0}; gbfread((void*)name, 1, 200, fin); diff --git a/gpsbabel/mapsend.cc b/gpsbabel/mapsend.cc index 26bc5333b..6aeb6c50e 100644 --- a/gpsbabel/mapsend.cc +++ b/gpsbabel/mapsend.cc @@ -486,7 +486,7 @@ void mapsend_track_disp(const waypoint* wpt) * * This is rumoured (but yet unconfirmed) to be fixed in f/w 5.12. */ - t = wpt->GetCreationTime(); + t = wpt->GetCreationTime().toTime_t(); if (t < last_time) { t = last_time; } diff --git a/gpsbabel/mapsource.cc b/gpsbabel/mapsource.cc index 3d10c591a..607024295 100644 --- a/gpsbabel/mapsource.cc +++ b/gpsbabel/mapsource.cc @@ -258,7 +258,7 @@ mps_wr_init(const char* fname) mpsmergeout = 0; } else { gbfclose(mps_file_out); - srand((unsigned) current_time()); + srand((unsigned) current_time().toTime_t()); for (;;) { /* create a temporary name based on a random char and the existing name */ @@ -1148,7 +1148,7 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte) QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) { testwpt = (waypoint*)elem; if (rte_datapoints == 0) { - uniqueValue = testwpt->GetCreationTime(); + uniqueValue = testwpt->GetCreationTime().toTime_t(); } if (testwpt->latitude > maxlat) { maxlat = testwpt->latitude; @@ -1188,7 +1188,7 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte) } if (uniqueValue == 0) { - uniqueValue = current_time(); + uniqueValue = current_time().toTime_t(); } /* route name */ @@ -1581,13 +1581,13 @@ mps_trackhdr_w(gbfile* mps_file, int mps_ver, const route_head* trk) QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) { if (trk_datapoints == 0) { testwpt = (waypoint*)elem; - uniqueValue = testwpt->GetCreationTime(); + uniqueValue = testwpt->GetCreationTime().toTime_t(); } trk_datapoints++; } if (uniqueValue == 0) { - uniqueValue = current_time(); + uniqueValue = current_time().toTime_t(); } /* track name */ @@ -1636,7 +1636,7 @@ static void mps_trackdatapoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt) { int lat, lon; - time_t t = wpt->GetCreationTime(); + time_t t = wpt->GetCreationTime().toTime_t(); char zbuf[10]; double mps_altitude = wpt->altitude; diff --git a/gpsbabel/nmea.cc b/gpsbabel/nmea.cc index a05126a11..390039f69 100644 --- a/gpsbabel/nmea.cc +++ b/gpsbabel/nmea.cc @@ -894,11 +894,11 @@ nmea_fix_timestamps(route_head* track) dt = (prev / SECONDS_PER_DAY) * SECONDS_PER_DAY; wpt->creation_time += dt; - if (wpt->creation_time > prev) { + if (wpt->creation_time.toTime_t() > prev) { wpt->creation_time+=SECONDS_PER_DAY; } } - prev = wpt->GetCreationTime(); + prev = wpt->GetCreationTime().toTime_t(); } } } @@ -1260,19 +1260,19 @@ nmea_trackpt_pr(const waypoint* wpt) if (sleepus >= 0) { gb_sleep(sleepus); } else { - long wait_time = wpt->GetCreationTime() - last_time; + long wait_time = wpt->GetCreationTime().toTime_t() - last_time; if (wait_time > 0) { gb_sleep(wait_time * 1000000); } } } - last_time = wpt->GetCreationTime(); + last_time = wpt->GetCreationTime().toTime_t(); } lat = degrees2ddmm(wpt->latitude); lon = degrees2ddmm(wpt->longitude); - time_t ct = wpt->GetCreationTime(); + time_t ct = wpt->GetCreationTime().toTime_t(); tm = gmtime(&ct); if (tm) { hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec; diff --git a/gpsbabel/osm.cc b/gpsbabel/osm.cc index a75782325..292f8b2cc 100644 --- a/gpsbabel/osm.cc +++ b/gpsbabel/osm.cc @@ -803,7 +803,7 @@ osm_waypt_disp(const waypoint* wpt) ((waypoint*)(wpt))->extra_data = id; gbfprintf(fout, " latitude, wpt->longitude); - if (wpt->creation_time) { + if (wpt->creation_time.isValid()) { QString time_string = wpt->CreationTimeXML(); gbfprintf(fout, " timestamp='%s'", qPrintable(time_string)); } diff --git a/gpsbabel/ozi.cc b/gpsbabel/ozi.cc index 81a5a31bc..5f670dd2e 100644 --- a/gpsbabel/ozi.cc +++ b/gpsbabel/ozi.cc @@ -150,7 +150,7 @@ ozi_alloc_fsdata(void) void ozi_get_time_str(const waypoint *waypointp, char *buff, gbsize_t buffsz) { - if (waypointp->creation_time) { + if (waypointp->creation_time.isValid()) { double time = (waypt_time(waypointp) / SECONDS_PER_DAY) + DAYS_SINCE_1990; snprintf(buff, buffsz, "%.7f", time); } else { diff --git a/gpsbabel/palmdoc.cc b/gpsbabel/palmdoc.cc index 12eb40aff..a136ff839 100644 --- a/gpsbabel/palmdoc.cc +++ b/gpsbabel/palmdoc.cc @@ -405,7 +405,7 @@ palmdoc_disp(const waypoint *wpt) { int latint, lonint; char tbuf[1024]; - time_t tm = wpt->GetCreationTime(); + time_t tm = wpt->GetCreationTime().toTime_t(); int32 utmz; double utme, utmn; char utmzc; @@ -507,7 +507,7 @@ palmdoc_disp(const waypoint *wpt) logpart = xml_findfirst(curlog, "groundspeak:date"); if (logpart) { - logtime = xml_parse_time(logpart->cdata); + logtime = xml_parse_time(logpart->cdata).toTime_t(); logtm = localtime(&logtime); if (logtm) { docprintf(15, @@ -584,7 +584,7 @@ data_write(void) } file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = DOC_TYPE; file_out->creator = DOC_CREATOR; file_out->version = 1; diff --git a/gpsbabel/pathaway.cc b/gpsbabel/pathaway.cc index 16a08ecac..3f11064bd 100644 --- a/gpsbabel/pathaway.cc +++ b/gpsbabel/pathaway.cc @@ -377,7 +377,7 @@ int ppdb_decode_tm(char *str, struct tm *tm) struct tm now; - tnow = current_time(); + tnow = current_time().toTime_t(); now = *localtime(&tnow); now.tm_year += 1900; now.tm_mon++; @@ -748,7 +748,7 @@ static void ppdb_write(void) } file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->creator = PPDB_MAGIC; file_out->version = 3; diff --git a/gpsbabel/pcx.cc b/gpsbabel/pcx.cc index b4a463d4b..7dbcaf319 100644 --- a/gpsbabel/pcx.cc +++ b/gpsbabel/pcx.cc @@ -321,13 +321,13 @@ gpsutil_disp(const waypoint *wpt) double lon,lat; int icon_token = 0; char tbuf[1024]; - time_t tm = wpt->GetCreationTime(); + time_t tm = wpt->GetCreationTime().toTime_t(); lon = degrees2ddmm(wpt->longitude); lat = degrees2ddmm(wpt->latitude); if (tm == 0) { - tm = current_time(); + tm = current_time().toTime_t(); } strftime(tbuf, sizeof(tbuf), "%d-%b-%y %I:%M:%S", localtime(&tm)); strupper(tbuf); @@ -407,7 +407,7 @@ pcx_track_disp(const waypoint *wpt) lon = degrees2ddmm(wpt->longitude); lat = degrees2ddmm(wpt->latitude); - const time_t ct = wpt->GetCreationTime(); + const time_t ct = wpt->GetCreationTime().toTime_t(); tm = gmtime(&ct); strftime(tbuf, sizeof(tbuf), "%d-%b-%y %H:%M:%S", tm); /* currently ...%T does nothing under Windows */ diff --git a/gpsbabel/pocketfms_bc.cc b/gpsbabel/pocketfms_bc.cc index 7d46ea542..c43b32d11 100644 --- a/gpsbabel/pocketfms_bc.cc +++ b/gpsbabel/pocketfms_bc.cc @@ -134,8 +134,8 @@ pocketfms_waypt_disp(const waypoint *wpt) memset(&bc, 0, sizeof(bc)); const time_t tt = wpt->GetCreationTime().toTime_t(); tm = localtime(&tt); - if (wpt->creation_time) { - const time_t tt = wpt->GetCreationTime(); + if (wpt->creation_time.isValid()) { + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = gmtime(&tt); } diff --git a/gpsbabel/psitrex.cc b/gpsbabel/psitrex.cc index 87bb17887..4eaff9312 100644 --- a/gpsbabel/psitrex.cc +++ b/gpsbabel/psitrex.cc @@ -488,13 +488,13 @@ psit_routehdr_w(gbfile *psit_file, const route_head *rte) QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) { testwpt = (waypoint *)elem; if (rte_datapoints == 0) { - uniqueValue = testwpt->GetCreationTime(); + uniqueValue = testwpt->GetCreationTime().toTime_t(); } rte_datapoints++; } if (uniqueValue == 0) { - uniqueValue = current_time(); + uniqueValue = current_time().toTime_t(); } /* route name */ @@ -648,13 +648,13 @@ psit_trackhdr_w(gbfile *psit_file, const route_head *trk) QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) { if (trk_datapoints == 0) { testwpt = (waypoint *)elem; - uniqueValue = testwpt->GetCreationTime(); + uniqueValue = testwpt->GetCreationTime().toTime_t(); } trk_datapoints++; } if (uniqueValue == 0) { - uniqueValue = current_time(); + uniqueValue = current_time().toTime_t(); } /* track name */ @@ -692,7 +692,7 @@ psit_trackhdr_w_wrapper(const route_head *trk) static void psit_trackdatapoint_w(gbfile *psit_file, const waypoint *wpt) { - time_t t = wpt->GetCreationTime(); + time_t t = wpt->GetCreationTime().toTime_t(); struct tm *tmTime = gmtime(&t); gbfprintf(psit_file, "%11.6f,%11.6f,", diff --git a/gpsbabel/quovadis.cc b/gpsbabel/quovadis.cc index 7e286129c..7a2cd2f13 100644 --- a/gpsbabel/quovadis.cc +++ b/gpsbabel/quovadis.cc @@ -219,7 +219,7 @@ data_write(void) } file_out->name[PDB_DBNAMELEN-1] = 0; file_out->attr = PDB_FLAG_BACKUP; - file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U; file_out->type = MYTYPE; /* CWpt */ file_out->creator = MYCREATOR; /* cGPS */ file_out->version = 1; diff --git a/gpsbabel/raymarine.cc b/gpsbabel/raymarine.cc index 830397679..d0e3186b7 100644 --- a/gpsbabel/raymarine.cc +++ b/gpsbabel/raymarine.cc @@ -349,7 +349,7 @@ write_waypoint(gbfile *fout, const waypoint *wpt, const int waypt_no, const char } } notes = csv_stringclean(notes, LINE_FEED); - time = (wpt->creation_time > 0) ? TIMET_TO_EXCEL(wpt->GetCreationTime()) : TIMET_TO_EXCEL(gpsbabel_time); + time = wpt->creation_time.isValid() ? TIMET_TO_EXCEL(wpt->GetCreationTime().toTime_t()) : TIMET_TO_EXCEL(gpsbabel_time); name = (char *)wpt->extra_data; gbfprintf(fout, "[Wp%d]" LINE_FEED diff --git a/gpsbabel/route.cc b/gpsbabel/route.cc index 1e5b7e7bf..6f2c735ff 100644 --- a/gpsbabel/route.cc +++ b/gpsbabel/route.cc @@ -655,12 +655,12 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap) tdata->max_cad = (int) thisw->cadence; } - if (thisw->GetCreationTime() && (thisw->GetCreationTime() < tdata->start)) { - tdata->start = thisw->GetCreationTime(); + if (thisw->GetCreationTime().isValid() && (thisw->GetCreationTime().toTime_t() < tdata->start)) { + tdata->start = thisw->GetCreationTime().toTime_t(); } - if (thisw->creation_time > tdata->end) { - tdata->end = thisw->GetCreationTime(); + if (thisw->creation_time.toTime_t() > tdata->end) { + tdata->end = thisw->GetCreationTime().toTime_t(); if (tdata->start == 0) { tdata->start = tdata->end; } diff --git a/gpsbabel/skyforce.cc b/gpsbabel/skyforce.cc index a78332233..0281ec99d 100644 --- a/gpsbabel/skyforce.cc +++ b/gpsbabel/skyforce.cc @@ -177,7 +177,7 @@ skyforce_waypt_disp_cb(const waypoint *wpt) if (global_opts.objective == trkdata) { struct tm tm; - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = *gmtime(&tt); strftime(buf + 2, sizeof(buf) - 2, "%d%m%y %H%M%S ", &tm); } else { diff --git a/gpsbabel/smplrout.cc b/gpsbabel/smplrout.cc index 2ff7a010c..9b25d336f 100644 --- a/gpsbabel/smplrout.cc +++ b/gpsbabel/smplrout.cc @@ -187,8 +187,8 @@ compute_xte(struct xte *xte_rec) } // if timestamps exist, distance to interpolated point if (wpt1->GetCreationTime() != wpt2->GetCreationTime()) { - frac = (double)(wpt3->GetCreationTime() - wpt1->GetCreationTime()) / - (wpt2->GetCreationTime() - wpt1->GetCreationTime()); + frac = (double)(wpt3->GetCreationTime().toTime_t() - wpt1->GetCreationTime().toTime_t()) / + (wpt2->GetCreationTime().toTime_t() - wpt1->GetCreationTime().toTime_t()); linepart(wpt1->latitude, wpt1->longitude, wpt2->latitude, wpt2->longitude, frac, &reslat, &reslon); diff --git a/gpsbabel/sort.cc b/gpsbabel/sort.cc index d13c67da7..dec8a74cd 100644 --- a/gpsbabel/sort.cc +++ b/gpsbabel/sort.cc @@ -70,7 +70,7 @@ sort_comp(const queue * a, const queue * b) case sm_description: return strcmp(x1->description, x2->description); case sm_time: - return x1->GetCreationTime() - x2->GetCreationTime(); + return x1->GetCreationTime().toTime_t() - x2->GetCreationTime().toTime_t(); default: abort(); return 0; /* Internal caller error. */ diff --git a/gpsbabel/src/core/datetime.h b/gpsbabel/src/core/datetime.h index 261f18410..4f08a88f4 100644 --- a/gpsbabel/src/core/datetime.h +++ b/gpsbabel/src/core/datetime.h @@ -45,9 +45,6 @@ public: DateTime(QDate date, QTime time) : QDateTime(date, time) {} DateTime(QDateTime dt) : QDateTime(dt) {} - // Handle time_tm tm = wpt->creation_time; - operator time_t() const { return toTime_t(); } - const time_t& operator=(const time_t& t) { setTime_t(t); return t; @@ -58,6 +55,14 @@ public: return toTime_t(); } + DateTime operator+(quint64 seconds) { + return DateTime::fromMSecsSinceEpoch(toMSecsSinceEpoch() + seconds*1000); + } + + DateTime operator-(quint64 seconds) { + return DateTime::fromMSecsSinceEpoch(toMSecsSinceEpoch() - seconds*1000); + } + // Integer form: YYMMDD int ymd() const { QDate d(date()); diff --git a/gpsbabel/stmsdf.cc b/gpsbabel/stmsdf.cc index 70f34858d..d5a14dcae 100644 --- a/gpsbabel/stmsdf.cc +++ b/gpsbabel/stmsdf.cc @@ -169,7 +169,7 @@ track_qsort_cb(const void *a, const void *b) const waypoint *wa = *(waypoint **)a; const waypoint *wb = *(waypoint **)b; - return wa->GetCreationTime() - wb->GetCreationTime(); + return wa->GetCreationTime().toTime_t() - wb->GetCreationTime().toTime_t(); } static void @@ -455,7 +455,7 @@ calculate(const waypoint *wpt, double *dist, double *speed, double *course, *dist = 0; /* calc. diffs on 32- and 64-bit hosts */ } - time = wpt->creation_time - trkpt_out->GetCreationTime(); + time = wpt->creation_time.toTime_t() - trkpt_out->GetCreationTime().toTime_t(); if (time == 0) { *speed = 0; } else { @@ -526,7 +526,7 @@ any_waypt_calc_cb(const waypoint *wpt) } if ((all_points == 0) && (this_points == 0)) { - start_time = wpt->GetCreationTime(); + start_time = wpt->GetCreationTime().toTime_t(); } this_points++; @@ -544,7 +544,7 @@ any_waypt_calc_cb(const waypoint *wpt) this_distance = this_distance + dist; if (trkpt_out != NULL) { - this_time += (wpt->GetCreationTime() - trkpt_out->GetCreationTime()); + this_time += (wpt->GetCreationTime().toTime_t() - trkpt_out->GetCreationTime().toTime_t()); } trkpt_out = (waypoint *)wpt; @@ -585,7 +585,7 @@ track_disp_wpt_cb(const waypoint *wpt) track_points++; all_track_points++; - time_t ct = wpt->GetCreationTime(); + time_t ct = wpt->GetCreationTime().toTime_t(); tm = *localtime(&ct); strftime(tbuf, sizeof(tbuf), "%d.%m.%Y,%H:%M.%S", &tm); @@ -669,8 +669,8 @@ route_disp_wpt_cb(const waypoint *wpt) static void track_disp_custom_cb(const waypoint *wpt) { - if (wpt->GetCreationTime() && (wpt->altitude != unknown_alt)) { - gbfprintf(fout, "%d,%.f\n", (int)(wpt->GetCreationTime() - start_time), wpt->altitude); + if (wpt->GetCreationTime().isValid() && (wpt->altitude != unknown_alt)) { + gbfprintf(fout, "%d,%.f\n", (int)(wpt->GetCreationTime().toTime_t() - start_time), wpt->altitude); } } diff --git a/gpsbabel/stmwpp.cc b/gpsbabel/stmwpp.cc index 9d3e42c7e..ca42b9c2f 100644 --- a/gpsbabel/stmwpp.cc +++ b/gpsbabel/stmwpp.cc @@ -238,7 +238,7 @@ stmwpp_waypt_cb(const waypoint *wpt) return; } - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = *gmtime(&tt); tm.tm_year += 1900; tm.tm_mon++; diff --git a/gpsbabel/subrip.cc b/gpsbabel/subrip.cc index dd48e2caf..a4bf563e2 100644 --- a/gpsbabel/subrip.cc +++ b/gpsbabel/subrip.cc @@ -92,17 +92,17 @@ subrip_prevwp_pr(const waypoint *waypointp) time_t starttime; time_t endtime; - if (prevwpp->GetCreationTime() >= time_offset) + if (prevwpp->GetCreationTime().toTime_t() >= time_offset) /* if this condition is not true, the waypoint is before the beginning of * the video and will be ignored */ { - starttime = gps_to_video_time(prevwpp->GetCreationTime()); + starttime = gps_to_video_time(prevwpp->GetCreationTime().toTime_t()); if (!waypointp) { endtime = starttime + 1; } else { - endtime = gps_to_video_time(waypointp->GetCreationTime()); + endtime = gps_to_video_time(waypointp->GetCreationTime().toTime_t()); } gbfprintf(fout, "%d\n", stnum); stnum++; @@ -120,7 +120,7 @@ subrip_prevwp_pr(const waypoint *waypointp) } else if WAYPT_HAS(prevwpp, speed) { gbfprintf(fout, "\n"); } - subrip_write_time(prevwpp->GetCreationTime()); + subrip_write_time(prevwpp->GetCreationTime().toTime_t()); gbfprintf(fout, " Lat=%0.5lf Lon=%0.5lf\n", prevwpp->latitude + .000005, prevwpp->longitude + .000005); @@ -148,7 +148,7 @@ subrip_trkpt_pr(const waypoint *waypointp) * way of solving this should be trivial to you :-) */ { - time_offset = sync_time(waypointp->GetCreationTime(), opt_videotime); + time_offset = sync_time(waypointp->GetCreationTime().toTime_t(), opt_videotime); } if (prevwpp) { diff --git a/gpsbabel/text.cc b/gpsbabel/text.cc index 28d47d47b..a1bacc4e1 100644 --- a/gpsbabel/text.cc +++ b/gpsbabel/text.cc @@ -97,7 +97,7 @@ text_disp(const waypoint *wpt) { int latint, lonint; char tbuf[1024]; - time_t tm = wpt->GetCreationTime(); + time_t tm = wpt->GetCreationTime().toTime_t(); int32_t utmz; double utme, utmn; char utmzc; @@ -203,7 +203,7 @@ text_disp(const waypoint *wpt) logpart = xml_findfirst(curlog, "groundspeak:date"); if (logpart) { - logtime = xml_parse_time(logpart->cdata); + logtime = xml_parse_time(logpart->cdata).toTime_t(); logtm = localtime(&logtime); if (logtm) { gbfprintf(file_out, diff --git a/gpsbabel/trackfilter.cc b/gpsbabel/trackfilter.cc index bfcf147a7..89074a539 100644 --- a/gpsbabel/trackfilter.cc +++ b/gpsbabel/trackfilter.cc @@ -354,8 +354,8 @@ trackfilter_fill_track_list_cb(const route_head *track) /* callback for track_d track_pts++; wpt = (waypoint *)elem; - if(wpt->creation_time == 0) timeless_pts++; - if (!(opt_merge && opt_discard) && (need_time != 0) && (wpt->creation_time == 0)) { + if (!wpt->creation_time.isValid()) timeless_pts++; + if (!(opt_merge && opt_discard) && (need_time != 0) && (!wpt->creation_time.isValid())) { fatal(MYNAME "-init: Found track point at %f,%f without time!\n", wpt->latitude, wpt->longitude); } @@ -525,7 +525,7 @@ trackfilter_merge(void) route_head *track = track_list[i].track; QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) { wpt = (waypoint *)elem; - if(wpt->creation_time != 0) { + if(wpt->creation_time.isValid()) { buff[j++] = waypt_dupe(wpt); } track_del_wpt(track, wpt); @@ -730,7 +730,7 @@ trackfilter_split(void) } if (interval > 0) { - double tr_interval = difftime(buff[j]->GetCreationTime(),buff[i]->GetCreationTime()); + double tr_interval = difftime(buff[j]->GetCreationTime().toTime_t(), buff[i]->GetCreationTime().toTime_t()); if (tr_interval <= interval) { new_track_flag = 0; } @@ -835,12 +835,12 @@ trackfilter_synth(void) RAD(wpt->longitude))); } if (opt_speed) { - if (oldtime != wpt->GetCreationTime()) { + if (oldtime != wpt->GetCreationTime().toTime_t()) { WAYPT_SET(wpt, speed, radtometers(gcdist( RAD(oldlat), RAD(oldlon), RAD(wpt->latitude), RAD(wpt->longitude))) / - labs(wpt->GetCreationTime()-oldtime)); + labs(wpt->GetCreationTime().toTime_t()-oldtime)); } else { WAYPT_UNSET(wpt, speed); } @@ -848,7 +848,7 @@ trackfilter_synth(void) } oldlat = wpt->latitude; oldlon = wpt->longitude; - oldtime = wpt->GetCreationTime(); + oldtime = wpt->GetCreationTime().toTime_t(); } } } @@ -915,12 +915,12 @@ trackfilter_range(void) /* returns number of track points left after filtering QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) { waypoint *wpt = (waypoint *)elem; - if (wpt->creation_time > 0) { - inside = ((wpt->GetCreationTime() >= start) && (wpt->GetCreationTime() <= stop)); + if (wpt->creation_time.isValid()) { + inside = ((wpt->GetCreationTime().toTime_t() >= start) && (wpt->GetCreationTime().toTime_t() <= stop)); } // If the time is mangled so horribly that it's // negative, toss it. - if (wpt->creation_time < 0) { + if (!wpt->creation_time.isValid()) { inside = 0; } @@ -1118,7 +1118,7 @@ trackfilter_faketime(void) /* returns number of track points left af QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) { waypoint *wpt = (waypoint *)elem; - if (opt_faketime != 0 && (wpt->creation_time == 0 || faketime.force)) { + if (opt_faketime != 0 && (!wpt->creation_time.isValid() || faketime.force)) { wpt->creation_time = QDateTime::fromTime_t(faketime.start); faketime.start += faketime.step; } diff --git a/gpsbabel/unicsv.cc b/gpsbabel/unicsv.cc index 4ae326bef..779e44e6c 100644 --- a/gpsbabel/unicsv.cc +++ b/gpsbabel/unicsv.cc @@ -1373,7 +1373,7 @@ unicsv_waypt_enum_cb(const waypoint *wpt) } if (wpt->creation_time.isValid()) { gb_setbit(&unicsv_outp_flags, fld_time); - if (wpt->creation_time >= SECONDS_PER_DAY) { + if (wpt->creation_time.toTime_t() >= SECONDS_PER_DAY) { gb_setbit(&unicsv_outp_flags, fld_date); } } @@ -1478,10 +1478,10 @@ unicsv_waypt_enum_cb(const waypoint *wpt) if (gc_data->is_available) { gb_setbit(&unicsv_outp_flags, fld_gc_is_available); } - if (gc_data->exported) { + if (gc_data->exported.isValid()) { gb_setbit(&unicsv_outp_flags, fld_gc_exported); } - if (gc_data->last_found) { + if (gc_data->last_found.isValid()) { gb_setbit(&unicsv_outp_flags, fld_gc_last_found); } if (!gc_data->placer.isEmpty()) { @@ -1729,16 +1729,16 @@ unicsv_waypt_disp_cb(const waypoint *wpt) } } if FIELD_USED(fld_date) { - if (wpt->creation_time >= SECONDS_PER_DAY) { + if (wpt->creation_time.toTime_t() >= SECONDS_PER_DAY) { struct tm tm; char buf[32]; - time_t time = wpt->GetCreationTime(); + time_t time = wpt->GetCreationTime().toTime_t(); if (opt_utc) { time += atoi(opt_utc) * SECONDS_PER_HOUR; tm = *gmtime(&time); } else { - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = *localtime(&tt); } tm.tm_year += 1900; @@ -1750,16 +1750,16 @@ unicsv_waypt_disp_cb(const waypoint *wpt) } } if FIELD_USED(fld_time) { - if (wpt->creation_time != 0) { + if (wpt->creation_time.isValid()) { struct tm tm; char buf[32], msec[12]; - time_t time = wpt->GetCreationTime(); + time_t time = wpt->GetCreationTime().toTime_t(); if (opt_utc) { time += atoi(opt_utc) * SECONDS_PER_HOUR; tm = *gmtime(&time); } else { - const time_t tt = wpt->GetCreationTime(); + const time_t tt = wpt->GetCreationTime().toTime_t(); tm = *localtime(&tt); } snprintf(buf, sizeof(buf), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec); @@ -1875,14 +1875,14 @@ unicsv_waypt_disp_cb(const waypoint *wpt) } if FIELD_USED(fld_gc_exported) { if (gc_data) { - unicsv_print_data_time(gc_data->exported); + unicsv_print_data_time(gc_data->exported.toTime_t()); } else { gbfputs(unicsv_fieldsep, fout); } } if FIELD_USED(fld_gc_last_found) { if (gc_data) { - unicsv_print_data_time(gc_data->last_found); + unicsv_print_data_time(gc_data->last_found.toTime_t()); } else { gbfputs(unicsv_fieldsep, fout); } diff --git a/gpsbabel/vitosmt.cc b/gpsbabel/vitosmt.cc index ba890d9a2..1556331fc 100644 --- a/gpsbabel/vitosmt.cc +++ b/gpsbabel/vitosmt.cc @@ -324,7 +324,7 @@ vitosmt_write(void) workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1); - now = current_time(); + now = current_time().toTime_t(); count = 0; position = 0; diff --git a/gpsbabel/waypt.cc b/gpsbabel/waypt.cc index a990b8a5f..45fd0fa75 100644 --- a/gpsbabel/waypt.cc +++ b/gpsbabel/waypt.cc @@ -542,11 +542,10 @@ gcgeodist(const double lat1, const double lon1, double waypt_time(const waypoint *wpt) { - if (wpt->creation_time <= 0) { + if (!wpt->creation_time.isValid()) { return (double) 0; } else { - - return ((double)wpt->creation_time + ((double)wpt->creation_time.time().msec() / 1000)); + return ((double)wpt->creation_time.toMSecsSinceEpoch()) / 1000.0; } } diff --git a/gpsbabel/wfff_xml.cc b/gpsbabel/wfff_xml.cc index 9e9330578..52043b12d 100644 --- a/gpsbabel/wfff_xml.cc +++ b/gpsbabel/wfff_xml.cc @@ -176,7 +176,7 @@ void wfff_chan(const char *args, const QXmlStreamAttributes* unused) void wfff_first(const char *args, const QXmlStreamAttributes* unused) { if (args) { - ap_first = xml_parse_time(args); + ap_first = xml_parse_time(args).toTime_t(); } } -- 2.30.2